package model

import "go.uber.org/zap/zapcore"

type UserInfo struct {
	Id           string `json:"_id"`
	Appid        string `json:"appid"`          //appid
	ApiKey       []byte `json:"apikey"`         //加密后的apikey
	Cmk          string `json:"cmk"`            //用于加密apikey的 cmk
	SmDefaultCmk string `json:"sm_default_cmk"` //默认的cmk
}

// UserinfoPartitionId 分区ID
func UserinfoPartitionId(id string) string {
	return "user_info:" + id
}

func (receiver *UserInfo) MarshalLogObject(enc zapcore.ObjectEncoder) error {
	enc.AddString("_id", receiver.Id)
	enc.AddString("appid", receiver.Appid)
	enc.AddBinary("apiKey", receiver.ApiKey)
	enc.AddString("cmk", receiver.Cmk)
	enc.AddString("smDefaultCmk", receiver.SmDefaultCmk)
	return nil
}
